/**
 * 点击复选框，反选设置
 * @param id 复选框的标识
 * @author Xiaopeng
 * @date 2013-07-29
 */
function clickTr(id){
	//若复选框禁用，则不设置复选框
	var ifDisabled = document.getElementById(id).disabled; //值为false表示复选框未被禁用
	if(!ifDisabled) {
		//复选框反选，说明：页面初始加载IE:defaultChecked为false，checked为true
		if(document.getElementById(id).defaultChecked) {
			document.getElementById(id).defaultChecked = false;
			document.getElementById(id).checked=false;
		} else {
			document.getElementById(id).defaultChecked = true;
			document.getElementById(id).checked=true;
		}
	}
}

/**
 * 复选框全选或全部取消选择
 * @author Xiaopeng
 * @date 2013-07-29
 */
function allCheck(id){
	var choosable; //标识复选框是否选择
	var input=document.getElementsByTagName("input");
	if(document.getElementById(id).value==1){ //全部选中状态
		choosable = false;
		document.getElementById(id).value=0;
	}else{
		choosable = true;
		document.getElementById(id).value=1;
	}
	for(var i=0;i<input.length;i++){
		if(input[i].type=="checkbox"){
			if(input[i].disabled) {
				continue;
			} else {
				input[i].checked = choosable;
				input[i].defaultChecked = choosable;
			}
		}
	}
}

/**
 * 读取勾选的复选框的值，并将其格式化输出
 * 输出格式：XXX,XXX,XXX
 * @param excludeCheckID 被排除统计的复选框ID
 * @returns {String}
 * @author Xiaopeng
 * @date 2013-07-29
 */
function formatCheckedValue(excludeCheckID) {
	var idList = "";
	var counter = 0;
	var input=document.getElementsByTagName("input");
	for(var index=0; index<input.length; index++){
		if(input[index].type=="checkbox" && input[index].name!=excludeCheckID && input[index].defaultChecked){
			idList += input[index].value + ",";
			counter++;
		}
	}
	if(counter > 0) idList = idList.substr(0, idList.length-1);
	return idList;
}

/**
 * 统计勾选的复选框的个数
 * @param excludeCheckID 被排除统计的复选框ID
 * @returns {Number}
 * @author Xiaopeng
 * @date 2013-07-29
 */
function countCheckedBox(excludeCheckID) {
	var counter = 0;
	var input=document.getElementsByTagName("input");
	for(var index=0; index<input.length; index++){
		if(input[index].type=="checkbox" && input[index].name!=excludeCheckID && input[index].defaultChecked){
			counter++;
		}
	}
	return counter;
}